package com.yujinglin.airline;

import com.yujinglin.util.testJson;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class airlineDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();
        Job job= Job.getInstance(conf);

        job.setJarByClass(airlineDriver.class);

        job.setMapperClass(airlineMapper.class);
        job.setReducerClass(airlineReducer.class);

        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(airlineWritable.class);

        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(airlineWritable.class);



        FileInputFormat.setInputPaths(job,new Path("/data/flights.csv"));
        FileOutputFormat.setOutputPath(job,new Path("/home/niit/Output2"));

//        FileInputFormat.setInputPaths(job,new Path("C:/Users/hanyiyang/Desktop/flights.csv"));
//        FileOutputFormat.setOutputPath(job,new Path("src/main/java/input/outputYu/Output2"));

        job.setPartitionerClass(airlinePartitioner.class);
        job.setNumReduceTasks(10);
//        分区
        boolean b= job.waitForCompletion(true);

        System.exit(b?0:1);


    }
}
